<template>
    <div class="home-category">
        <div class="title-bar clear-float">
            <div class="title fl">{{ categoryData.title }}</div>
            <div class="fr">
                <router-link :to="'/search?category=' + categoryData.id">MORE</router-link>
            </div>
        </div>
        <div class="content-wrapper">
            <el-row :gutter="8">
                <el-col :span="6">
                    <router-link class="link" :to="'/detail?id=' + spec[0].id">
                        <img :src="spec[0].recommendPicture" class="g-img w-100 g-2" alt="">
                    </router-link>
                </el-col>
                <el-col :span="12">
                    <el-row :gutter="8">
                        <el-col v-for="g in normal" :span="12" class="normal-item">
                            <router-link class="link" :to="'/detail?id=' + g.id">
                                <img :src="g.recommendPicture" class="g-img w-100 g-1" alt="">
                                <div class="g-title">
                                    <div class="box">
                                        <p class="text t1">{{ g.name }}</p>
                                        <el-divider></el-divider>
                                        <p class="text t2">{{ g.description }}</p>
                                    </div>
                                </div>
                            </router-link>
                        </el-col>
                    </el-row>
                </el-col>
                <el-col :span="6">
                    <router-link class="link" :to="'/detail?id=' + spec[1].id">
                        <img :src="spec[1].recommendPicture" class="g-img w-100 g-2" alt="">
                    </router-link>
                </el-col>
            </el-row>
        </div>
    </div>
</template>

<script>
// 1.将原来页面中的重复部分拷贝到组件中...
export default {
    name: "HomeCategory",
    props:{
        title:{
            type:String,
            default:'分类'
        },
        categoryData:{
            type:Object,
            require:true
        }
    },
    data(){
        return {
            spec:this.categoryData.goods.specRecommend,
            normal:this.categoryData.goods.normalRecommend
        }
    },
    mounted() {
    }
}
</script>

<style scoped lang="less">

.home-category {
    margin-top: 20px;

    .link {
        display: inline-block;
        width: 100%;
        position: relative;

        img {
            display: block;
        }

        .g-title {
            position: absolute;
            text-align: center;
            background-color: rgba(255, 255, 255, 0.7);
            padding: 15px;
            bottom: 20px;
            left: 20px;
            right: 20px;
        }

        .box {
            border: solid 1px rgba(0, 0, 0, 0.5);
            padding: 10px;
        }

        .t1 {
            font-size: 16px;
            color: #f00
        }

        .t2 {
            font-size: 14px;
        }
    }

    .g-1 {
        height: 224px;
    }

    .g-2 {
        height: 454px;
    }

    .title-bar {
        font-size: 16px;
        line-height: 44px;

        .title {
            font-size: 20px;
        }
    }
}

.normal-item{
    margin-top: 3px;
    &:nth-child(2),&:nth-child(1){
        margin-top: 0;
    }
}

</style>